package com.yn.admin.zy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yn.common.enums.AuditStatusEnum;
import com.yn.common.enums.CarStatusEnum;
import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.request.zyorder.ZyServiceRegionPriceRequest;
import com.yn.common.request.zyorder.ZyServiceRegionPriceSearch;
import com.yn.common.response.sc.BaseResult;
import com.yn.common.response.zyorder.ZyServiceRegionPriceResponse;
import com.yn.service.service.ZyServiceRegionPriceService;
import com.yn.service.zy.TCarManageService;
import com.yn.service.zy.model.dto.TCarManageDTO;
import com.yn.service.zy.model.query.TCarManageQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("api/zy/service/region")
@Api(tags = "转运区域配置相关接口")
public class ZyServiceRegionPriceController {

    @Autowired
    private ZyServiceRegionPriceService zyServiceRegionPriceService;

    /**
     * 服务项区域配置价格新增你修改
     */
    @ApiOperation(value = "服务项区域配置价格新增或修改")
    @PostMapping("/saveOrUpdateServiceRegionPrice")
    public BaseResult<String> saveOrUpdateServiceRegionPrice(@RequestBody @Validated ZyServiceRegionPriceRequest zyServiceRegionPriceRequest) {
        Boolean b = zyServiceRegionPriceService.saveOrUpdateServiceRegionPrice(zyServiceRegionPriceRequest);
        if (b) {
            return BaseResult.success();
        }
        return BaseResult.failed();
    }

    /**
     * 服务项区域配置价格详情
     */
    @ApiOperation(value = "服务项区域配置价格详情")
    @GetMapping("/getServiceRegionPrice")
    public BaseResult<ZyServiceRegionPriceResponse> getServiceRegionPrice(Integer id) {
        ZyServiceRegionPriceResponse serviceRegionPrice = zyServiceRegionPriceService.getServiceRegionPrice(id);

        return BaseResult.success(serviceRegionPrice);
    }

    /**
     * 删除服务项区域配置价格
     */
    @DeleteMapping("/del")
    @ApiOperation(value = "删除服务项区域配置价格")
    public BaseResult<String> del(Integer id) {
        zyServiceRegionPriceService.del(id);

        return BaseResult.success();
    }

    /**
     * 区域配置列表查询
     *
     * @param zyServiceRegionPriceSearch 搜索条件
     * @param pageParamRequest           分页参数
     * @return
     */
    @GetMapping("/listServiceRegionPriceList")
    @ApiOperation(value = "区域配置列表分页查询")
    BaseResult<BasePage<ZyServiceRegionPriceResponse>> listServiceRegionPriceList(ZyServiceRegionPriceSearch zyServiceRegionPriceSearch,
                                                                                  PageParamRequest pageParamRequest) {
        List<ZyServiceRegionPriceResponse> zyServiceRegionPriceResponses =
                zyServiceRegionPriceService.listServiceRegionPriceList(zyServiceRegionPriceSearch, pageParamRequest);

        BasePage<ZyServiceRegionPriceResponse> categoryCommonPage = BasePage.restPage(zyServiceRegionPriceResponses);
        return BaseResult.success(categoryCommonPage);
    }
}
